package com.todo.strategy.online.application.frontend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.strategy.online.application.frontend.service.StrategyPortalAggService;
import com.todo.strategy.online.iface.StrategyPortalIface;
import com.todo.strategy.online.iface.request.*;
import com.todo.strategy.online.iface.response.StrategyBaseVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/5/21 14:24
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/strategy")
@Tag(name = "攻略首页前台接口", description = "攻略首页前台接口")
public class StrategyPortalController implements StrategyPortalIface {

    @Resource
    private StrategyPortalAggService strategyPortalAggService;

    @Override
    @Operation(summary = "根据关键词搜索攻略列表（平台+用户）")
    @PostMapping("/searchStrategy")
    public BizPageResponse<StrategyBaseVO> searchStrategy(SearchStrategyParam param) {
        if (param == null) {
            return BizPageResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.success("查询失败，请刷新后重新操作");
        }
        return strategyPortalAggService.searchStrategy(param);
    }

    @Override
    @Operation(summary = "根据关键词搜索平台攻略列表")
    @PostMapping("/searchPlatformStrategy")
    public BizPageResponse<StrategyBaseVO> searchPlatformStrategy(SearchPlatformStrategyParam param) {
        if (param == null) {
            return BizPageResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.success("查询失败，请刷新后重新操作");
        }
        return strategyPortalAggService.searchPlatformStrategy(param);
    }

    @Override
    @Operation(summary = "根据用户关注的feed流查询攻略列表")
    @PostMapping("/followFeedStreamStrategy")
    public BizPageResponse<StrategyBaseVO> followFeedStreamStrategy(FollowFeedStreamStrategyParam param) {
        if (param == null) {
            return BizPageResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.success("查询失败，请刷新后重新操作");
        }
        return strategyPortalAggService.followFeedStreamStrategy(param);
    }

    @Override
    @Operation(summary = "攻略推荐列表入口 V1版本")
    @PostMapping("/recommendPlatformStrategyListV1")
    public BizPageResponse<StrategyBaseVO> recommendPlatformStrategyListV1(RecommendStrategyListV1Param param) {
        if (param == null) {
            return BizPageResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.success("查询失败，请刷新后重新操作");
        }
        return strategyPortalAggService.recommendPlatformStrategyListV1(param);
    }
}
